package com.luna.cloudworm.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * User: haitao
 * Date: 2020/7/1
 */
@Configuration
public class MyRedissonConfig {
    /**
     * 鎵�鏈夊Redisson鐨勪娇鐢ㄩ兘鏄�氳繃RedissonClient 瀵硅薄
     *
     * @return
     * @throws Exception
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redisson() throws Exception {
        //1. 鍒涘缓閰嶇疆
        Config config = new Config();
        config.useSingleServer().setAddress("redis://redis.cloudworm:6379");
        // 2. 鏍规嵁Config 鍒涘缓鍑篟edissonClient
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }


}
